Fix transaction chunking on QUIC batch send #26642
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem
The chunking logic was reversed. It was always creating chunks, where each chunk contains 128 transactions. So if a batch had 20,000 transactions, it'll create 157 chunks. For a batch of 100 transactions, it'll create only 1 chunk.
The batching code will work better if we can create more chunks, so that multiple streams can be used to transmit the transactions in parallel.
Summary of Changes
This PR reverses the chunking logic. It'll try to create up to
QUIC_MAX_UNSTAKED_CONCURRENT_STREAMS
chunks now. For a 100 transaction batch, it'll create 100 chunks. Any batch with more thanQUIC_MAX_UNSTAKED_CONCURRENT_STREAMS
transactions will haveQUIC_MAX_UNSTAKED_CONCURRENT_STREAMS
chunks.This change uncovered some issues on the streamer side of code as well. If the client is a staked node, but doesn't have enough stake, the receiver will not allocate enough QUIC streams for it. See here for more analysis of this #26340 (comment)
This PR adds some improvements on the streamer side as well, to assign a minimal number of streams to a staked client. More cleanup/fixes are needed to address all the concerns in #26340
Fixes #